package com.weiyi.weiman.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @Author zhang
 * @Date 2021/5/6 下午10:25
 * @Description mybatis-plus设置时间配置类
 * @Version 1.0
 **/
@Component
public class MyBetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("gwtUpdate", new Date(), metaObject);
        this.setFieldValByName("gwtCreate", new Date(), metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("gwtUpdate", new Date(), metaObject);
    }
}
